/**
 * 判断req请求中，哪个对象有参数就返回哪个参数
 * @date 2021-03-19
 * @param {any} req
 * @returns {any} null说明请求没有传递参数
 */
function getParams(req) {
  let query = req.query
  console.log('<-------query-------')
  console.log(query)
  console.log('-------query------->')
  let keysQuery = Object.keys(query)
  if (keysQuery.length > 0) {
    return query
  }
  let body = req.body
  console.log('<-------body-------')
  console.log(body)
  console.log('-------body------->')
  let keysBody = Object.keys(body)
  if (keysBody.length > 0) {
    return body
  }
  let params = req.params
  console.log(params)
  let keysParams = Object.keys(params)
  if (keysParams.length > 0) {
    return params
  }
  return null
}

exports.getParams = getParams
